package com.broadengate.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.broadengate.dao.BankDao;
import com.broadengate.model.Bank;
import com.broadengate.model.Card;

/******
 * 提供银行与数据库的交互方法
 * 方法主要有addBank()添加银行；findBankByBankNO()从银行号查找银行
 */
public class BankDaoImpl extends HibernateDaoSupport implements BankDao {
	
	@SuppressWarnings("unchecked")
	public void addBank(Bank bank) {
		
		getHibernateTemplate().save(bank);

	}

	public Bank findBankByBankNO(String bankNO){
		
		List<Bank> list = new ArrayList<Bank>();
		list= getHibernateTemplate().find("from Bank bank where bank.id='"+bankNO+"'");		
		return null!=list && 0!=list.size() ? (Bank)list.get(0) : null;
	}
}
